
Option Strict On
Option Explicit On

Imports System
Imports System.Web

Imports DotNetNuke.Entities.Users

Namespace DGZfP.EventPublisher

    ''' <remarks>Yes, it uses DAL+</remarks>
    Public Class SourceController

        Public Shared Sub Add(ByVal Source As SourceInfo)
            DataProvider.Instance.ExecuteNonQuery("EventPublisher_Sources_Add", Source.ModuleID, Source.Google_Calendar_ID, Source.Context, Source.Active, Source.Source_Type, Source.Source_Setting_100, Source.Source_Setting_2000, Source.Source_Setting_50a, Source.Source_Setting_50b, Source.Mapping_ID, Source.Mapping_Start, Source.Mapping_End, Source.Mapping_Title, Source.Mapping_Content, "", Source.Mapping_Location, Source.Mapping_AllDay)
        End Sub

        Public Shared Sub Delete(ByVal SourceId As Integer)
            DataProvider.Instance.ExecuteNonQuery("EventPublisher_Sources_Delete", SourceId)
        End Sub

        Public Shared Sub Delete(ByVal Source As SourceInfo)
            Delete(Source.Source_ID)
        End Sub

        Public Shared Sub Update(ByVal Source As SourceInfo)
            DataProvider.Instance.ExecuteNonQuery("EventPublisher_Sources_Update", Source.Source_ID, Source.ModuleID, Source.Google_Calendar_ID, Source.Context, Source.Active, Source.Source_Type, Source.Source_Setting_100, Source.Source_Setting_2000, Source.Source_Setting_50a, Source.Source_Setting_50b, Source.Mapping_ID, Source.Mapping_Start, Source.Mapping_End, Source.Mapping_Title, Source.Mapping_Content, "", Source.Mapping_Location, Source.Mapping_AllDay)
        End Sub

        Public Shared Function [Get](ByVal SourceId As Integer) As SourceInfo
            Return CBO.FillObject(Of SourceInfo)(DataProvider.Instance.ExecuteReader("EventPublisher_Sources_Get", SourceId))
        End Function

        Public Shared Function GetList(ByVal ModuleId As Integer) As Generic.IList(Of SourceInfo)
            Return CBO.FillCollection(Of SourceInfo)(DataProvider.Instance.ExecuteReader("EventPublisher_Sources_GetList", ModuleId))
        End Function

        Public Shared Function GetNextSourceToRun() As SourceInfo
            Return CBO.FillObject(Of SourceInfo)(DataProvider.Instance.ExecuteReader("EventPublisher_Sources_GetNextRun"))
        End Function

        Public Shared Function GetSettingsControlPath(ByVal ProviderName As String) As String
            Return "~" + Definition.PathOfModule + "SourceSettings/" + ProviderName + "/" + ProviderName + SourceTypeSettings.FILENAME_SettingsASCX
        End Function

    End Class
End Namespace
